home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plstar.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  5KB  |  215 lines

  1. #include "plplot.h"
  2. #include "declare.h"
  3. #include <stdio.h>
  4.  
  5. /* Asks for number of plotting device, and call plbeg to divide the */
  6. /* page into nx by ny subpages */
  7.  
  8. static int mk=0, sp=0;
  9.  
  10. void plstar(nx,ny)
  11. int nx, ny;
  12. {
  13.    int dev,lev;
  14.  
  15.    glev(&lev);
  16.    if (lev != 0) plend();
  17.       
  18.    printf("\nPlotting Options:");
  19.    printf("\n < 1> Amiga");
  20.    printf("\n < 2> LaserJet II file    (landscape)");
  21.    printf("\n < 3> LaserJet II file    (portrait)");
  22.    printf("\n < 4> imPRESS     file    (landscape)");
  23.    printf("\n < 5> imPRESS     file    (portrait)");
  24.    printf("\n < 6> Tektronix   file    (landscape)");
  25.    printf("\n < 7> Tektronix   file    (portrait)");
  26.    printf("\n");
  27.    printf("\nEnter device number: ");
  28.    scanf("%d",&dev);
  29.    while(getchar() != '\n') /* Read all of line including new line char */
  30.        ;
  31.    plbeg(dev,nx,ny);
  32. }
  33.  
  34. /* Initializes the graphics device "dev"  */
  35. void grbeg(dev)
  36. int dev;
  37. {
  38.    int termin, phyxmi, phyxma, phyymi, phyyma;
  39.    void grinit(), grclr(), grcol(), grgra();
  40.  
  41.    /* Set up device specific stuff */
  42.  
  43.    /* Use setpxl to set the device dots per mm in the x and y directions */
  44.    /* dpmmx = dots/mm in x direction (float) */
  45.    /* dpmmy = dots/mm in y direction (float) */
  46.    /* setpxl(dpmmx,dpmmy); */
  47.  
  48.    /* PLPLOT assumes that the plot origin is in the lower left corner */
  49.    /* with y increasing upward and x increasing to the right */
  50.    /* Use setphy to specify how PLPLOT should translate plotting coords */
  51.    /* to device coords */
  52.    /* xmindev = minimum x device coordinate (int) */
  53.    /* xmaxdev = maximum x device coordinate (int) */
  54.    /* ymindev = minimum y device coordinate (int) */
  55.    /* ymaxdev = maximum y device coordinate (int) */
  56.    /* setphy(xmindev,xmaxdev,ymindev,ymaxdev); */
  57.  
  58.    if (dev == 1) {
  59.      setpxl(2.52,2.25);
  60.      setphy(0,639,0,399);
  61.      termin = 1;
  62.    }
  63.    else if (dev == 2) {
  64.        setpxl(5.905,5.905);  /* 150 dpi mode */
  65.        termin = 0;
  66.        setphy(0,1409,0,1103);
  67.    }
  68.    else if (dev == 3) {
  69.        setpxl(5.905,5.905);  /* 150 dpi mode */
  70.        termin = 0;
  71.        setphy(0,1103,1409,0);
  72.    }
  73.    else if (dev == 4) {
  74.        setpxl(11.81,11.81);  /* 300 dpi */
  75.        termin = 0;
  76.        setphy(0,2999,0,2249);
  77.    }
  78.    else if (dev == 5) {
  79.        setpxl(11.81,11.81);  /* 300 dpi */
  80.        termin = 0;
  81.        setphy(2249,0,0,2999);
  82.    }
  83.    else if (dev == 6 )  {
  84.        setpxl(4.771,4.653);
  85.        termin = 0;
  86.        setphy(0,1023,0,779);
  87.    }
  88.    else if (dev == 7)  {
  89.        setpxl(4.653,4.771);
  90.        termin = 0;
  91.        setphy(779,0,0,1023);
  92.    }
  93.    else {
  94.      printf("\nUnknown output device\n");
  95.      exit(1);
  96.    }
  97.  
  98.    sdev(dev,termin,0);
  99.    grinit();
  100.  
  101.    /* Set default sizes, fonts, and colors */
  102.    plschr(4.0,1.0);
  103.    plssym(4.0,1.0);
  104.    plsmaj(3.0,1.0);
  105.    plsmin(1.5,1.0);
  106.    satt(1,1);
  107.  
  108.    /* Switch to graphics mode and clear screen */
  109.    grgra();
  110.    grclr();
  111.    grcol();
  112.    plstyl(0,&mk,&sp);
  113.       
  114.    gphy(&phyxmi,&phyxma,&phyymi,&phyyma);
  115.    sclp(phyxmi,phyxma,phyymi,phyyma);
  116. }
  117.  
  118. /* Clears the graphics screen */
  119. void grclr()
  120. {
  121.       if (device == 1)
  122.         amiclr();
  123.       else if (device == 2 || device == 3)
  124.         jetclr();
  125.       else if (device == 4 || device == 5)
  126.         impclr();
  127.       else if (device == 6 || device == 7)
  128.         tekclr();
  129. }
  130.  
  131. /* Sets up the line colour to value in global variable "colour" */
  132. void grcol()
  133. {
  134.       if (device == 1)
  135.         amicol(colour);
  136. }
  137.  
  138. /* Initializes the graphics device */
  139. void grinit()
  140. {
  141.       if (device == 1)
  142.         amiini();
  143.       else if (device == 2 || device == 3)
  144.         jetini();
  145.       else if (device == 4 || device == 5)
  146.         impini();
  147.       else if (device == 6 || device == 7)
  148.         tekini();
  149. }
  150.  
  151. /* Switches to graphics mode */
  152. void grgra()
  153. {
  154.       if (device == 1)
  155.         amigra();
  156.       else if (device == 2 || device == 3)
  157.         jetgra();
  158.       else if (device == 4 || device == 5)
  159.         impgra();
  160.       else if (device == 6 || device == 7)
  161.         tekgra();
  162.  
  163.       graphx = 1;
  164. }
  165.  
  166. /* Draws a line from (x1,x2) to (x2,y2), used by genlin() */
  167. /* Notice how x and y are swapped to switch from the default */
  168. /* orientation */
  169. void grline(x1,y1,x2,y2)
  170. int x1,y1,x2,y2;
  171. {
  172.       if (device == 1)
  173.         amilin(x1,y1,x2,y2);
  174.       else if (device == 2)
  175.         jetlin(y1,x1,y2,x2);
  176.       else if (device == 3)
  177.         jetlin(x1,y1,x2,y2);
  178.       else if (device == 4)
  179.         implin(x1,y1,x2,y2);
  180.       else if (device == 5)
  181.         implin(y1,x1,y2,x2);
  182.       else if (device == 6)
  183.         teklin(x1,y1,x2,y2);
  184.       else if (device == 7)
  185.         teklin(y1,x1,y2,x2);
  186. }
  187.  
  188. /* Switches to text mode */
  189. void grtext()
  190. {
  191.       if (device == 1)
  192.         amitex();
  193.       else if (device == 2 || device == 3)
  194.         jettex();
  195.       else if (device == 4 || device == 5)
  196.         imptex();
  197.       else if (device == 6 || device == 7)
  198.         tektex();
  199.  
  200.       graphx = 0;
  201. }
  202.  
  203. /* Called by plend to tidy up graphics device */
  204. void grtidy()
  205. {
  206.       if (device == 1)
  207.         amitid();
  208.       else if (device == 2 || device == 3)
  209.         jettid();
  210.       else if (device == 4 || device == 5)
  211.         imptid();
  212.       else if (device == 6 || device == 7)
  213.         tektid();
  214. }
  215.